package com.pace.mock;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import java.io.File;

import static org.mockito.Mockito.times;

@RunWith(PowerMockRunner.class)
// We prepare PartialMockClass for test because it's final or we need to mock private or static methods
@PrepareForTest(TestCase1.class)
public class YourTestCase {
    @Test
    public void spyingWithPowerMock() {
        TestCase1 classUnderTest = PowerMockito.spy(new TestCase1());
        File file = PowerMockito.mock(File.class);
        // use Mockito to set up your expectation
        Mockito.when(classUnderTest.callArgumentInstance(file)).thenReturn(true);

        // execute your test
        classUnderTest.callArgumentInstance(file);

        // Use Mockito.verify() to verify result
        Mockito.verify(classUnderTest, times(2)).callArgumentInstance(file);
    }
}
